package com.acwing.lc.part1;

/**
 * @author rkc
 * @date 2022/9/15 10:48
 */
public class LC50Pow {

    public double myPow(double x, int n) {
        double ans = 1;
        boolean minus = n < 0;
        long k = Math.abs((long) n);
        while (k != 0) {
            if ((k & 1) == 1) ans *= x;
            x *= x;
            k >>= 1;
        }
        return minus ? 1 / ans : ans;
    }
}
